﻿package  
{
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	
	public class PetSkillUI extends MovieClip 
	{
		public var skillCount:int = 0;
		public var skill:Array;
		public var skillNameArray:Array;
		public var skillButtonArray:Array;
		
		public var px:int = 136;
		public var py:int = 161;
		
		public function PetSkillUI() 
		{
			skill = new Array();
			skillNameArray = new Array();
			skillButtonArray = new Array();
			
			skillNameArray.push( skillNameText0 );
			skillNameArray.push( skillNameText1 );
			skillNameArray.push( skillNameText2 );
			skillNameArray.push( skillNameText3 );
			skillNameArray.push( skillNameText4 );
			skillNameArray.push( skillNameText5 );
			skillNameArray.push( skillNameText6 );
			
			skillButtonArray.push( skillBtn0 );
			skillButtonArray.push( skillBtn1 );
			skillButtonArray.push( skillBtn2 );
			skillButtonArray.push( skillBtn3 );
			skillButtonArray.push( skillBtn4 );
			skillButtonArray.push( skillBtn5 );
			skillButtonArray.push( skillBtn6 );
			
			for ( var i:int = 0 ; i < skillNameArray.length ; i++ )
			{
				skillNameArray[ i ].mouseEnabled = false;
				skillButtonArray[ i ].addEventListener( MouseEvent.CLICK , onClick(i) );
			}
			
			skill.push( new Object() );
			skill.push( new Object() );
			skill.push( new Object() );
			skill.push( new Object() );
			skill.push( new Object() );
			skill.push( new Object() );
			skill.push( new Object() );
			
			clear();
		}
		
		private function onClick( i:int ):Function
		{
			return function foo( e:MouseEvent ):void
			{
				setExplain( skill[ i ].e );
			}
		}
		
		
		public function setExplain( e:String ):void
		{
			explainText.text = e;
			explainText.visible = true;
		}
		
		public function setName( n:String ):void
		{
			nameText.text = n;
			nameText.visible = true;
		}
		
		public function addSkill( n:String , e:String ):void
		{
			skill[ skillCount ].n = null;
			skill[ skillCount ].e = null;
			
			skill[ skillCount ].n = n;
			skill[ skillCount ].e = e;
			
			skillNameArray[ skillCount ].text = n;
			skillButtonArray[ skillCount ].visible = true;
			skillNameArray[ skillCount ].visible = true;
			
			skillCount++;
		}
		
		public function clear():void
		{
			skillCount = 0;
			
			for ( var i:int = 0 ; i < skillNameArray.length ; i++ )
			{
				skillNameArray[ i ].visible = false;
				skillButtonArray[ i ].visible = false;
			}
			
			explainText.visible = false;
			nameText.visible = false;
		}
		
		
	}
	
}


